home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / tk / CrtErrHdlr.man < prev    next >
Encoding:
Text File  |  1992-08-24  |  9.8 KB  |  327 lines

  1. '\"
  2. '\" Copyright 1990 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. '\" $Header: /user6/ouster/wish/man/RCS/CrtErrHdlr.man,v 1.4 92/05/31 15:09:11 ouster Exp $ SPRITE (Berkeley)
  11. '\" 
  12. .\" The definitions below are for supplemental macros used in Sprite
  13. .\" manual entries.
  14. .\"
  15. .\" .HS name section [date [version]]
  16. .\"    Replacement for .TH in other man pages.  See below for valid
  17. .\"    section names.
  18. .\"
  19. .\" .AP type name in/out [indent]
  20. .\"    Start paragraph describing an argument to a library procedure.
  21. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  22. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  23. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  24. .\"    needed;  use .AS below instead)
  25. .\"
  26. .\" .AS [type [name]]
  27. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  28. .\"    name are examples of largest possible arguments that will be passed
  29. .\"    to .AP later.  If args are omitted, default tab stops are used.
  30. .\"
  31. .\" .BS
  32. .\"    Start box enclosure.  From here until next .BE, everything will be
  33. .\"    enclosed in one large box.
  34. .\"
  35. .\" .BE
  36. .\"    End of box enclosure.
  37. .\"
  38. .\" .VS
  39. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  40. .\"    of man pages.
  41. .\"
  42. .\" .VE
  43. .\"    End of vertical sidebar.
  44. .\"
  45. .\" .DS
  46. .\"    Begin an indented unfilled display.
  47. .\"
  48. .\" .DE
  49. .\"    End of indented unfilled display.
  50. .\"
  51. '\"    # Heading for Sprite man pages
  52. .de HS
  53. .if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  54. .if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  55. .if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  56. .if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  57. .if t .wh -1.3i ^B
  58. .nr ^l \\n(.l
  59. .ad b
  60. ..
  61. '\"    # Start an argument description
  62. .de AP
  63. .ie !"\\$4"" .TP \\$4
  64. .el \{\
  65. .   ie !"\\$2"" .TP \\n()Cu
  66. .   el          .TP 15
  67. .\}
  68. .ie !"\\$3"" \{\
  69. .ta \\n()Au \\n()Bu
  70. \&\\$1    \\fI\\$2\\fP    (\\$3)
  71. .\".b
  72. .\}
  73. .el \{\
  74. .br
  75. .ie !"\\$2"" \{\
  76. \&\\$1    \\fI\\$2\\fP
  77. .\}
  78. .el \{\
  79. \&\\fI\\$1\\fP
  80. .\}
  81. .\}
  82. ..
  83. '\"    # define tabbing values for .AP
  84. .de AS
  85. .nr )A 10n
  86. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  87. .nr )B \\n()Au+15n
  88. .\"
  89. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  90. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  91. ..
  92. '\"    # BS - start boxed text
  93. '\"    # ^y = starting y location
  94. '\"    # ^b = 1
  95. .de BS
  96. .br
  97. .mk ^y
  98. .nr ^b 1u
  99. .if n .nf
  100. .if n .ti 0
  101. .if n \l'\\n(.lu\(ul'
  102. .if n .fi
  103. ..
  104. '\"    # BE - end boxed text (draw box now)
  105. .de BE
  106. .nf
  107. .ti 0
  108. .mk ^t
  109. .ie n \l'\\n(^lu\(ul'
  110. .el \{\
  111. .\"    Draw four-sided box normally, but don't draw top of
  112. .\"    box if the box started on an earlier page.
  113. .ie !\\n(^b-1 \{\
  114. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  115. .\}
  116. .el \}\
  117. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  118. .\}
  119. .\}
  120. .fi
  121. .br
  122. .nr ^b 0
  123. ..
  124. '\"    # VS - start vertical sidebar
  125. '\"    # ^Y = starting y location
  126. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  127. .de VS
  128. .mk ^Y
  129. .ie n 'mc \s12\(br\s0
  130. .el .nr ^v 1u
  131. ..
  132. '\"    # VE - end of vertical sidebar
  133. .de VE
  134. .ie n 'mc
  135. .el \{\
  136. .ev 2
  137. .nf
  138. .ti 0
  139. .mk ^t
  140. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  141. .sp -1
  142. .fi
  143. .ev
  144. .\}
  145. .nr ^v 0
  146. ..
  147. '\"    # Special macro to handle page bottom:  finish off current
  148. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  149. '\"    # page bottom macro.
  150. .de ^B
  151. .ev 2
  152. 'ti 0
  153. 'nf
  154. .mk ^t
  155. .if \\n(^b \{\
  156. .\"    Draw three-sided box if this is the box's first page,
  157. .\"    draw two sides but no top otherwise.
  158. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  159. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  160. .\}
  161. .if \\n(^v \{\
  162. .nr ^x \\n(^tu+1v-\\n(^Yu
  163. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  164. .\}
  165. .bp
  166. 'fi
  167. .ev
  168. .if \\n(^b \{\
  169. .mk ^y
  170. .nr ^b 2
  171. .\}
  172. .if \\n(^v \{\
  173. .mk ^Y
  174. .\}
  175. ..
  176. '\"    # DS - begin display
  177. .de DS
  178. .RS
  179. .nf
  180. .sp
  181. ..
  182. '\"    # DE - end display
  183. .de DE
  184. .fi
  185. .RE
  186. .sp .5
  187. ..
  188. .HS Tk_CreateErrorHandler tk
  189. .BS
  190. .SH NAME
  191. Tk_CreateErrorHandler, Tk_DeleteErrorHandler \- handle X protocol errors
  192. .SH SYNOPSIS
  193. .nf
  194. \fB#include <tk.h>\fR
  195. .sp
  196. Tk_ErrorHandler
  197. \fBTk_CreateErrorHandler\fR(\fIdisplay, error, request, minor, proc, clientData\fR)
  198. .sp
  199. \fBTk_DeleteErrorHandler\fR(\fIhandler\fR)
  200. .SH ARGUMENTS
  201. .AS "Tk_ErrorHandler" clientData
  202. .AP Display *display in
  203. Display whose errors are to be handled.
  204. .AP int error in
  205. Match only error events with this value in the \fIerror_code\fR
  206. field.  If -1, then match any \fIerror_code\fR value.
  207. .AP int request in
  208. Match only error events with this value in the \fIrequest_code\fR
  209. field.  If -1, then match any \fIrequest_code\fR value.
  210. .AP int minor in
  211. Match only error events with this value in the \fIminor_code\fR
  212. field.  If -1, then match any \fIminor_code\fR value.
  213. .AP Tk_ErrorProc *proc in
  214. Procedure to invoke whenever an error event is received for
  215. \fIdisplay\fR and matches \fIerror\fR, \fIrequest\fR, and \fIminor\fR.
  216. NULL means ignore any matching errors.
  217. .AP ClientData clientData in
  218. Arbitrary one-word value to pass to \fIproc\fR.
  219. .AP Tk_ErrorHandler handler in
  220. Token for error handler to delete (return value from a previous
  221. call to \fBTk_CreateErrorHandler\fR).
  222. .BE
  223.  
  224. .SH DESCRIPTION
  225. .PP
  226. \fBTk_CreateErrorHandler\fR arranges for a particular procedure
  227. (\fIproc\fR) to be called whenever certain protocol errors occur on a
  228. particular display (\fIdisplay\fR).  Protocol errors occur when
  229. the X protocol is used incorrectly, such as attempting to map a window
  230. that doesn't exist.  See the Xlib documentation for \fBXSetErrorHandler\fR
  231. for more information on the kinds of errors that can occur.
  232. For \fIproc\fR to be invoked
  233. to handle a particular error, five things must occur:
  234. .IP [1]
  235. The error must pertain to \fIdisplay\fR.
  236. .IP [2]
  237. Either the \fIerror\fR argument to \fBTk_CreateErrorHandler\fR
  238. must have been -1, or the \fIerror\fR argument must match
  239. the \fIerror_code\fR field from the error event.
  240. .IP [3]
  241. Either the \fIrequest\fR argument to \fBTk_CreateErrorHandler\fR
  242. must have been -1, or the \fIrequest\fR argument must match
  243. the \fIrequest_code\fR field from the error event.
  244. .IP [4]
  245. Either the \fIminor\fR argument to \fBTk_CreateErrorHandler\fR
  246. must have been -1, or the \fIminor\fR argument must match
  247. the \fIminor_code\fR field from the error event.
  248. .IP [5]
  249. The protocol request to which the error pertains must have been
  250. made when the handler was active (see below for more information).
  251. .PP
  252. \fIProc\fP should have arguments and result that match the
  253. following type:
  254. .nf
  255. .RS
  256. typedef int Tk_ErrorProc(
  257. .RS
  258. ClientData \fIclientData\fR,
  259. XErrorEvent *\fIerrEventPtr\fR);
  260. .RE
  261. .RE
  262. .fi
  263. The \fIclientData\fP parameter to \fIproc\fR is a copy of the \fIclientData\fP
  264. argument given to \fBTcl_CreateErrorHandler\fR when the callback
  265. was created.  Typically, \fIclientData\fR points to a data
  266. structure containing application-specific information that is
  267. needed to deal with the error.  \fIErrEventPtr\fR is
  268. a pointer to the X error event.
  269. The procedure \fIproc\fR should return an integer value.  If it
  270. returns 0 it means that \fIproc\fR handled the error completely and there
  271. is no need to take any other action for the error.  If it returns
  272. non-zero it means \fIproc\fR was unable to handle the error.
  273. .PP
  274. If a value of NULL is specified for \fIproc\fR, all matching errors
  275. will be ignored:  this will produce the same result as if a procedure
  276. had been specified that always returns 0.
  277. .PP
  278. If more than more than one handler matches a particular error, then
  279. they are invoked in turn.  The handlers will be invoked in reverse
  280. order of creation:  most recently declared handler first.
  281. If any handler returns 0, then subsequent (older) handlers will
  282. not be invoked.  If no handler returns 0, then Tk invokes X'es
  283. default error handler, which prints an error message and aborts the
  284. program.  If you wish to have a default handler that deals with errors
  285. that no other handler can deal with, then declare it first.
  286. .PP
  287. The X documentation states that ``the error handler should not call
  288. any functions (directly or indirectly) on the display that will
  289. generate protocol requests or that will look for input events.''
  290. This restriction applies to handlers declared by \fBTk_CreateErrorHandler\fR;
  291. disobey it at your own risk.
  292. .PP
  293. \fBTk_DeleteErrorHandler\fR may be called to delete a
  294. previously-created error handler.  The \fIhandler\fR argument
  295. identifies the error handler, and should be a value returned by
  296. a previous call to \fBTk_CreateEventHandler\fR.
  297. .PP
  298. A particular error handler applies to errors resulting
  299. from protocol requests generated between
  300. the call to \fBTk_CreateErrorHandler\fR and the call to
  301. \fBTk_DeleteErrorHandler\fR.  However, the actual callback
  302. to \fIproc\fR may not occur until after the \fBTk_DeleteErrorHandler\fR
  303. call, due to buffering in the client and server.
  304. If an error event pertains to
  305. a protocol request made just before calling \fBTk_DeleteErrorHandler\fR,
  306. then the error event may not have been processed
  307. before the \fBTk_DeleteErrorHandler\fR
  308. call.  When this situation arises, Tk will save information about
  309. the handler and
  310. invoke the handler's \fIproc\fR later when the error event
  311. finally arrives.
  312. If an application wishes to delete an error handler and know
  313. for certain that all relevant errors have been processed,
  314. it should first call \fBTk_DeleteErrorHandler\fR and then
  315. call \fBXSync\fR;  this will flush out any buffered requests and errors,
  316. but will result in a performance penalty because
  317. it requires communication to and from the X server.  After the
  318. \fBXSync\fR call Tk is guaranteed not to call any error
  319. handlers deleted before the \fBXSync\fR call.
  320. .PP
  321. For the Tk error handling mechanism to work properly, it is essential
  322. that application code never calls \fBXSetErrorHandler\fR directly;
  323. applications should use only \fBTk_CreateErrorHandler\fR.
  324.  
  325. .SH KEYWORDS
  326. callback, error, event, handler
  327.